import java.util.Random;

public class randomItemGenerator {

	private enum Quality { LOW, MEDIUM, HIGH }
	private String FoodNames[][] = new String[][] { {"a hunk of bread", "bread" }, {"a hunk of cheese", "cheese" }, { "a bottle of wine", "wine" }, {"a sliced ham", "ham" }, { "a jug of cider", "cider" }, {"a plate of fresh chicken", "fresh chicken" }, {"a leg of lamb", "lamb"}, {"a bowl of soup", "soup"} };
	private Random random = new Random();
	
	public randomItemGenerator() {
		
	}
	
	
	public Consumable randomConsumable(String a, String b) {
		Consumable result = null;
		Quality quality = calcQuality(b);
		switch (quality) {
		case LOW:
			int nextRandom = random.nextInt(FoodNames.length);
			result = new Consumable(a, FoodNames[nextRandom][0], FoodNames[nextRandom][1], ("It is a simple " + FoodNames[nextRandom][0].substring(2)), 0, (random.nextInt(5) + 10));
			break;
		case MEDIUM:
			result = new Consumable(a, "a phial of medicine", "phial of medicine", "The exact concoction of this potion is unknown, but it radiates with healing power", 0, (random.nextInt(10) + 50));
			break;
		case HIGH:
			result = new Consumable(a, "a glowing red potion", "glowing red potion", "The ingredients of this concoction is a secret, passed down from generation to generation of apothacery.", 0, (random.nextInt(50) + 100));
			break;
		}
		return result;
	}
	
	public Consumable randomPoison(String a, String b) {
		Consumable result = new Consumable(a, "some rotten bread", "rotten bread", "It looks vile", 0, -10);
		return result;
	}
	
	
	public Weapon randomWeapon(String a, String b) {
		Weapon result = null;
		Quality quality = calcQuality(b);
		String Quality = null;
		String Weapon_Type = null;
		String Material = null;
		int nextRandom = random.nextInt(100);

		switch (quality) {
		case LOW:
			if (nextRandom > 70) {
				Quality = "common";
			} else {
				Quality = "crude";
			}
			if (nextRandom > 95) {
				Material = "silver";
			} else if (nextRandom > 75) {
				Material = "steel";
			} else if (nextRandom > 40) {
				Material = "iron";
			} else if (nextRandom > 10) {
				Material = "bronze";
			} else if (nextRandom > 0) {
				Material = "bone";
			}
			break;
		case MEDIUM:
			if (nextRandom > 80) {
				Quality = "exquisite";
			} else {
				Quality = "superior";
			}
			if (nextRandom > 80) {
				Material = "silver";
			} else if (nextRandom > 40) {
				Material = "steel";
			} else if (nextRandom > 20) {
				Material = "iron";
			} else if (nextRandom > 10) {
				Material = "bronze";
			} else if (nextRandom > 0) {
				Material = "bone";
			}
			break;
		case HIGH:
			if (nextRandom > 90) {
				Quality = "legendary";
			} else {
				Quality = "epic";
			}
			if (nextRandom > 70) {
				Material = "silver";
			} else if (nextRandom > 30) {
				Material = "steel";
			} else if (nextRandom > 20) {
				Material = "iron";
			} else if (nextRandom > 10) {
				Material = "bronze";
			} else if (nextRandom > 0) {
				Material = "bone";
			}
			break;
		}
		
		int weaponRoll = random.nextInt(6);
		if (weaponRoll == 0) {
			Weapon_Type = "sword";
		} else if (weaponRoll == 1) {
			Weapon_Type = "axe";
		} else if (weaponRoll == 2) {
			Weapon_Type = "dagger";
		} else if (weaponRoll == 3) {
			Weapon_Type = "greatsword";
		} else if (weaponRoll == 4) {
			Weapon_Type = "maul";
		} else if (weaponRoll == 5) {
			Weapon_Type = "greataxe";
		}
		
		result = new Weapon(a, Quality, Material, Weapon_Type);
		return result;
	}
	
	
	public Quality calcQuality(String a) {
		Quality result = null;
		if (a.equalsIgnoreCase("low")) {
			result = Quality.LOW;
		} else if (a.equalsIgnoreCase("medium")) {
			result = Quality.MEDIUM;
		} else if (a.equalsIgnoreCase("high")) {
			result = Quality.HIGH;
		}
		return result;
	}
	
	
}
